#include "src/mysql.h"
#include "src/redis.h"
#include "src/util.h"
#include "src/server.h"
#include <thread>
#include <cstdio>

int main() {
    // 初始化 MySQL 连接
    init_mysql();
    // 初始化 Redis
    init_redis();
    // 创建并启动服务器
    Server server;
    std::thread server_thread(&Server::start, &server);

    // 插入单个测试用户并刷新缓存
    const char* email = "365";
    const char* test_username = "365";
    const char* test_password = "test_paghfdssword";
    insert_test_user(test_username,email, test_password);
    int authenticated = authenticate_user(test_username, test_password);
    printf("Authenticated: %d\n", authenticated);

    // 批量刷新多个用户的Redis缓存
    const char *usernames[] = {"user1", "user2", "user3"};
    int num_users = sizeof(usernames) / sizeof(usernames[0]);
    refresh_multiple_users_redis_cache(usernames, num_users);

    // 等待服务器线程结束
    server_thread.join();

    close_mysql();

    return 0;
}
